﻿/*
 * @Autor: PK
 * @Date: 2021/12/11 18:23:SS
 */

using System;
using ShkSimulation.core.dao.output.result;

namespace ShkSimulation.core.dao.statistic.impl {

	public class DefaultResultCollectionListener : ResultListener {
		
		private Result doubleResult;
		private readonly string uniqueKey;

		public DefaultResultCollectionListener(string uniqueKey, ExtractReportersAction action = null) {
			this.uniqueKey = uniqueKey ?? throw new ArgumentNullException(nameof(uniqueKey));
			this.doubleResult = new DefaultDoubleResult(uniqueKey);
			this.Action = action;
		}

		public override string Uniquekey => uniqueKey;

		protected override void AppendData(CollectionReportData collectionReportData) {
			doubleResult.AppendData(collectionReportData.ReporterCollectionUniqueKey, collectionReportData);
		}

		public override Result Export() {
			return doubleResult;
		}
	}
}